
package TrabalhoEda;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;


/**
 * @author Joao Alturas
 *
 */
public class Desempenho {
	
		@SuppressWarnings("unused")
		private static final String fname = ("D:\\EDA13_14\\SaveTempo.txt");
		
		private ArrayList<Double> calculaPonto;
	    private ArrayList<Double> mediaTempo;

			public Desempenho()
			{
				 this.calculaPonto = new ArrayList<Double>();
	             this.mediaTempo = new ArrayList<Double>();
			}
			
			public void setPontoTempo(double tempo){
	            this.calculaPonto.add(tempo);
	    }
			
			public void setMediaTempo(){
	            this.mediaTempo.add(this.calculaMedia());           
	            this.calculaPonto.clear();
	    }

			
			
	    	private Double calculaMedia() {
	    		double soma = 0;
	            for(double somaTempo : this.calculaPonto) {
	                    soma += somaTempo;
	            }
	            return (soma / this.calculaPonto.size());
			}

			public void writeLog(String fname, ArrayList<Double> mediaTempo) throws IOException
	    	   {
	    	      BufferedWriter out = null;
	    	      try 
	    	      {	 
	    	    	 
	    			out = new BufferedWriter(new FileWriter(fname, true));
	    			System.out.println("ola");
	    	        out.write(mediaTempo + "\n"); 
	    	        
	    	        
	    	      } 
	    	      catch (IOException e) 
	    	      {
	    	         throw e;
	    	      }
	    	      finally
	    	      {
	    	         out.close();
	    	      }
	    	   }    
			       
			

}
